function Node(value) {
	this.value = value;
	this.left = null;
	this.right = null
}

var a = new Node("a");
var b = new Node("b");
var c = new Node("c");
var d = new Node("d");
var e = new Node("e")
var f = new Node("f");
var g = new Node("g");

a.left = c;
a.right = b;
c.left = f;
c.right = g;
b.left = d;
b.right = e;


//对于二叉树来说  （深度优先搜索） 和 （先序遍历） 的顺序是一样的
function deepSearch(root, target) {
	if(root === null) return false;
	if(root.value === target) return true;
	var left = deepSearch(root.left, target);  //遍历左子树
	var right = deepSearch(root.right, target);     //遍历右子树
	return left || right
}

console.log(deepSearch(a,"f"))
console.log(deepSearch(a,"g"))
console.log(deepSearch(b,"f"))